package com.study.designPattern.factorymethod;

import com.utils.ClassUtils;

import java.util.List;
import java.util.Random;

/**
 * @Author HBZ
 * @Date 2019/5/10 10:34
 * @Description 设成静态方法
 */
public class HumanFactory2  {

    public static <T extends Human> T createHuman(Class<T> c) {

        //定义一个生产的人种
        Human human=null;
        try {
        //产生一个人种
            human = (T)Class.forName(c.getName()).newInstance();
        } catch (Exception e) {
            System.out.println("人种生成错误！ ");
        }
        return (T)human;
    }

}
